<?php


	/* Functions in this file */
	/**************************/

	// ClearFlag($flag)
	// GetAlignment()
	// GetBorderRect()
	// GetFontSetting()
	// GetFontSettingConstRef()
	// GetFontSettingRef()
	// GetMFCClassName()
	// GetMFCClassSchema()
	// GetRect()
	// GetText()
	// HasBorder()
	// IsAligned($alignment)
	// IsAlignedCenter()
	// IsAlignedLeft()
	// IsAlignedRight()
	// IsEmpty()
	// IsFlagSet($flag)
	// IsValidAlignment($alignment)
	// SetAlignment($alignment)
	// SetFlag($flag)
	// SetFontSetting(&$fontSetting)
	// SetRect($rect)
	// SetText($text)
?>
<?php
	 
	 
	class FloatingText {
		 
		 
		// Constants
		// Default constants
		const DEFAULT_TEXT = "Text";
		static public $DEFAULT_RECT = array(0, 0, 0, 0);
		const DEFAULT_FLAGS = self::DEFAULT_ALIGNMENT;
		const DEFAULT_ALIGNMENT = self::alignLeft;
		 
		// Default constants
		const alignLeft = 0x00000001;
		const alignCenter = 0x00000002;
		const alignRight = 0x00000004;
		const alignMask = 0x00000007;
		const border = 0x00000008;
		 
		 
		 
		protected $m_text = self::DEFAULT_TEXT;
		protected $m_rect = array(0, 0, 0, 0);
		protected $m_flags = self::DEFAULT_FLAGS;
		protected $m_fontSetting;
		 
		// Constructor/Destructor
		 
		 
		function GetMFCClassName() {
			return "CFloatingText";
		}
		 
		 
		function GetMFCClassSchema() {
			return 1;
		}
		 
		// Text Functions
		 
		 
		 
		function SetText($text) {
			if (!$text) return 0;
			$this->m_text = $text;
			return 1;
		}
		 
		 
		function GetText() {
			return ($this->m_text);
		}
		 
		// Rect Functions
		 
		 
		function SetRect($rect) {
			$this->m_rect = $rect;
		}
		 
		 
		function GetRect() {
			return ($this->m_rect);
		}
		 
		function IsEmpty() {
			return (($this->m_rect[2] == 0) && ($this->m_rect[3] == 0));
		}
		 
		// Flag Functions
		 
		 
		function ClearFlag($flag) {
			$this->m_flags &= ~$flag;
		}
		 
		 
		 
		function IsFlagSet($flag) {
			return (($this->m_flags & $flag) == $flag);
		}
		 
		// Alignment Functions
		 
		 
		function IsValidAlignment($alignment) {
			return (($alignment == self::alignLeft) || ($alignment == self::alignCenter) || ($alignment == self::alignRight));
		}
		 
		 
		 
		function SetAlignment($alignment) {
			if (!$this->IsValidAlignment($alignment)) return 0;
			$this->ClearFlag(self::alignMask);
			$this->SetFlag($alignment);
			return 1;
		}
		 
		 
		function GetAlignment() {
			return ($this->m_flags & self::alignMask);
		}
		 
		 
		 
		function IsAligned($alignment) {
			if (!$this->IsValidAlignment($alignment)) return 0;
			return ($this->IsFlagSet($alignment));
		}
		 
		 
		function IsAlignedLeft() {
			return ($this->IsAligned(self::alignLeft));
		}
		 
		 
		function IsAlignedCenter() {
			return ($this->IsAligned(self::alignCenter));
		}
		 
		 
		function IsAlignedRight() {
			return ($this->IsAligned(self::alignRight));
		}
		 
		 
		 
		function SetBorder($set = 1) {
			if ($set) $this->SetFlag(self::border);
				else $this->ClearFlag(self::border);
		}
		 
		 
		function HasBorder() {
			return ($this->IsFlagSet(self::border));
		}
		 
		// Font $this->Setting Functions
		 
		 
		function SetFontSetting(&$fontSetting) {
			$this->m_fontSetting = $fontSetting;
		}
		 
		 
		function GetFontSetting() {
			return ($this->m_fontSetting);
		}
		 
		 
		function & GetFontSettingRef() {
			return ($this->m_fontSetting);
		}
		 
		 
		static function & GetFontSettingConstRef() {
			return ($this->m_fontSetting);
		}
		 
		 
		function FloatingText($text = NULL, $rect = NULL, $flags = NULL, &$fontSetting = NULL) {
	
			$this->m_fontSetting = new FontSetting (); 
			if (!$text) return 0;
			
			
		}
		 
		 
		 
		 
		function DoSerialize(&$stream) {
		 
		
			WRITE_CSTRING ($stream,$this->m_text);

			WRITE_MFC_RECT ($stream,$this->m_rect);

			WRITE_BYTE ($stream,$this->m_flags);
			
			$this->m_fontSetting = new FontSetting ();
			$this->m_fontSetting->DoSerialize($stream);


			return 1;
		}
		 
		 
		 
		function DoDeserialize(&$stream) {
		 
		
			$this->m_text = READ_CSTRING ($stream);
		
			READ_MFC_RECT ($stream,$this->m_rect);
		 
			$this->m_flags = READ_BYTE ($stream);
		 
			$this->m_fontSetting->DoDeserialize($stream);
		
		}
		
		// Flag Functions
		 
		 
		function SetFlag($flag) {
			 
			//------Last Checked------//
			// - Dec 7, 2004
			 
			// Clear old $alignment $flag if new $flag is $alignment $flag
			if ((($flag & self::alignLeft) == self::alignLeft) | (($flag & self::alignCenter) == self::alignCenter) | (($flag & self::alignRight) == self::alignRight))
				$this->ClearFlag(self::alignMask);
			$this->m_flags |= $flag;
		}
		 
		 
		 
		function GetBorderRect() {
			 
			//------Last Checked------//
			// - Dec 7, 2004
			$returnValue = array();
			 
			$returnValue[0] = ($this->m_rect[0] - 2);
			$returnValue[1] = ($this->m_rect[1] - 1);
			$returnValue[2] = ($this->m_rect[2] + 1);
			$returnValue[3] = ($this->m_rect[3] + 1);
			return ($returnValue);
		}
		 
		 
	}
	 
?>